package com.bluedon.ism.commons.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;




public class WriteUtil{

	private static final Log logger = LogFactory.getLog(WriteUtil.class);
	
	public static final String SYS_DEFAULT_CHARSET = "UTF-8";
	
	
	public static void write(HttpServletResponse response, String str) {
		write(response, str,SYS_DEFAULT_CHARSET);
	}

	
	private static void write(HttpServletResponse response, String str, String charset) {
		response.setContentType("text/html;charset=" + charset);
		PrintWriter pw = null;
		try{
			pw = response.getWriter();
			pw.write(str);
			pw.flush();
		}catch (IOException e){
			e.printStackTrace();
			throw new RuntimeException(e);  
		}finally {
		    if (pw!=null)
		        pw.close();
		}
		
	}
}
